
***************************************************************;
** Create 2011 denominator file matched with HEDIS 2011 data **;
***************************************************************;

options ls=76 nofmterr;

libname raw '/data/Medicare_P01_2009/data/HEDIS/rawdata';
libname new '/data/Medicare_P01_2009/data/HEDIS/sasdata';


data a; set new.hedis2011s;

     zip5=1*substr(bene_zip_cd,1,5);

     proc sort; by zip5;


data zip; set new.zipinfo;

     proc sort; by zip5;


data a01(drop=orig_hic hic_match); merge a(in=ok) zip; by zip5;

     if ok;

data nonkaiser; set a01;

     if org_id='H0524' then delete;

data oldkaiser0; set a01;

     if org_id='H0524';

     proc sort; by id_num;

data id11; set raw.linkid2011; proc sort; by id_num;

data oldkaiser; merge id11 oldkaiser0(in=ok); by id_num;

     if ok;
     drop org_id org_name;
     proc sort; by hic_number;


**** Reading Separated Kaiser ID ***;

data ncak; set raw.nca_kaiser2011;

  if c1='hic_number' then delete;

  length hic_number $12;
  hic_number=substr(c1,1,12);

  length org_id $5;
  org_id='HN524';
  org_name='KAISER FOUNDATION HP, NORTHERN CA';

data scak; set raw.sca_kaiser2011;

     length hic_number $12;

     hic_number=substr(v_H0524KAISER,1,12);
  
     length org_id $5;
     org_id = 'HS524';
     org_name ='KAISER FOUNDATION HP, SOUTHERN CA';

data nk; set ncak; keep hic_number org_id org_name;
data sk; set scak; keep hic_number org_id org_name;


data newkaiser; set nk sk;  proc sort; by hic_number;

data kaiser; merge oldkaiser(in=a) newkaiser(in=b); by hic_number;

     if a and b;
     drop hic_number;


data new.hedis2011; set nonkaiser kaiser;

     proc freq; tables org_id;

endsas;










